

/*
This do-file reproduces the main analysis of the paper "Dismantling the \Jungle":
Migrant Relocation and Extreme Voting in France", by P. Vertier, M. Viskanic, and M. Gamalerio

Specifically, it reproduces the following Tables and Figures reported in the manuscript:

Table 1 - Panel A
Table 1 - Panel B
Table 2
Table 3
Table A1
Table A3
Table A4
Figure A2


*/

log using "Main_Analysis", replace text

clear

use "Main dataset.dta"

*************
***Table 1***
*************

*************
***Panel A***

preserve

foreach var of varlist log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_  ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  {


drop if `var'==.


}
***

keep if period>=2

 
reg log_fn  CAO_period_3 CAO period_3  , cluster( codeinsee)
 
qui outreg2 using "Table 1_Panel A", ///
keep(CAO_period_3 CAO period_3) ctitle(no controls) bdec(3) nocons excel tex `append'

***Add control variables***   
 
reg log_fn  CAO_period_3 CAO period_3 i.period   ///
log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_ ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ , cluster( codeinsee)
 
qui outreg2 using "Table 1_Panel A", ///
keep(CAO_period_3 CAO period_3) ctitle(controls) bdec(3) nocons excel tex `append'

       
  *** FE***   
 
reg log_fn  CAO_period_3 i.period , cluster( codeinsee) absorb(codeinsee)
 
qui outreg2 using "Table 1_Panel A", ///
keep(CAO_period_3) ctitle(no controls, time FE, municipal FE) bdec(3) nocons excel tex `append'
    
	
 ***Add control variables + FE***   
 
reg log_fn  CAO_period_3 i.period   ///
log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_ ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ , cluster( codeinsee) absorb(codeinsee)
 
qui outreg2 using "Table 1_Panel A", ///
keep(CAO_period_3) ctitle(controls, time FE, municipal FE) bdec(3) nocons excel tex `append'	
	
	
 ***Add control variables + FE + spillovers***   
 
reg log_fn  CAO_period_3 ring5_CAO_period_3 ring10_CAO_period_3 ring15_CAO_period_3 i.period   ///
log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_ ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ , cluster( codeinsee) absorb(codeinsee)
 
qui outreg2 using "Table 1_Panel A", ///
keep(CAO_period_3 ring5_CAO_period_3 ring10_CAO_period_3 ring15_CAO_period_3) ctitle(controls, time FE, municipal FE) bdec(3) nocons excel tex `append'	
		
	
 restore  
 count 	
 
************* 
***Panel B***
 
preserve
keep if period==3

foreach var of varlist  CAO num_group_vv evol2_fn_2012_2017 /// 
coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ ///
   CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ {


drop if `var'==.

}
***

***Reduced form***

 reg  evol2_fn_2012_2017  num_group_vv       coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg, cluster( numdep)

qui outreg2 using "Table 1_Panel B", ///
keep(num_group_vv) ctitle(Reduced Form, all controls, regions FE) bdec(3) nocons excel tex `append'

***First Stage***

 reg  CAO  num_group_vv       coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg, cluster( numdep)
   
   test num_group_vv

qui outreg2 using "Table 1_Panel B", ///
keep(num_group_vv) ctitle(First Stage, all controls, regions FE) bdec(3) nocons excel tex addstat(F-statistic, r(F))  `append' 

***OLS***

 reg  evol2_fn_2012_2017  CAO       coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg, cluster( numdep)

qui outreg2 using "Table 1_Panel B", ///
keep(CAO) ctitle(OLS, all controls, regions FE) bdec(3) nocons excel tex  `append'  

***IV controlling only for tourism***

ivreg2  evol2_fn_2012_2017 (CAO= num_group_vv)      coastal  log_hotel_rooms    log_tot_pop_   i.reg, cluster( numdep) first

qui outreg2 using "Table 1_Panel B", ///
keep(CAO coastal  log_hotel_rooms) ctitle(IV, control for tourism only, regions FE) bdec(3) nocons excel tex addstat(F-statistic, e(widstat)) `append'


***IV controlling for everything***


 ivreg2  evol2_fn_2012_2017 (CAO= num_group_vv)      coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg, cluster( numdep) first

qui outreg2 using "Table 1_Panel B", ///
keep(CAO coastal  log_hotel_rooms) ctitle(IV, all controls, regions FE) bdec(3) nocons excel tex addstat(F-statistic, e(widstat)) `append'
 
restore 
 
 
 
*************
***Table 2***
*************

***Columns 1-2***
 
 preserve
foreach var of varlist log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_  ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  {


drop if `var'==.


}
***

keep if period>=2

foreach var of varlist  log_melenchon log_turnout   {
 
  
 
qui reg `var'  CAO_period_3 i.period   ///
log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_ ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ , cluster( codeinsee) absorb(codeinsee)

 
 outreg2 using "Table 2", ///
keep(CAO_period_3) ctitle(DiD, `var', controls, time FE, municipal FE) bdec(3) nocons excel tex `append'
   
 
 }
 *** 

restore  
 
 ***Columns 3-4***

preserve
keep if period==3

foreach var of varlist  CAO num_group_vv evol2_fn_2012_2017 /// 
coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ ///
   CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ {


drop if `var'==.


}
***

 
foreach var of varlist  evol2_melench_2012_2017 evol2_turnout     {
  
  
 ivreg2  `var' ( CAO= num_group_vv)      coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_  CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg, cluster( numdep) first

qui outreg2 using "Table 2", ///
keep( CAO) ctitle(IV, `var', all controls, regions FE) bdec(3) nocons excel tex addstat(F-statistic, e(widstat))  `append'
  
  
  
  }
****
 
restore


*************
***Table 3***
*************

***columns 1-2***

preserve
foreach var of varlist log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_  ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  {


drop if `var'==.


}
***

keep if period>=2

g missing_size=(tot_places_CAO_per1000==0&CAO==1)
tab missing_size, m

sum tot_places_CAO_per1000 if CAO==1, de
replace tot_places_CAO_per1000=0.0350716 if missing_size==1
sum tot_places_CAO_per1000  if CAO==1, de

***create standardized version of size of the centre***

egen tot_places_CAO_per1000_st=std(tot_places_CAO_per1000)
g CAO_period_3_size=tot_places_CAO_per1000_st*CAO_period_3
   

reg log_fn  CAO_period_3 i.period   ///
log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_ ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ , cluster( codeinsee) absorb(codeinsee)
 
qui outreg2 using "Table 3", ///
keep(CAO_period_3) ctitle(controls, time FE, municipal FE) bdec(3) nocons excel tex `append'
   
      
reg log_fn  CAO_period_3 CAO_period_3_size i.period   ///
log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_ ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ , cluster( codeinsee) absorb(codeinsee)
 
qui outreg2 using "Table 3", ///
keep(CAO_period_3 CAO_period_3_size) ctitle(controls, time FE, municipal FE) bdec(3) nocons excel tex `append'

 
***columns 3-4*** 
 
keep if period==3

foreach var of varlist  CAO num_group_vv evol2_fn_2012_2017 /// 
coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ ///
   CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ {


drop if `var'==.


}
***

g num_group_vv_size=tot_places_CAO_per1000_st*num_group_vv
g CAO_size=tot_places_CAO_per1000_st*CAO

ivreg2  evol2_fn_2012_2017 ( CAO= num_group_vv)      coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_    CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_   i.reg, cluster( numdep) first

qui outreg2 using "Table 3", ///
keep( CAO) ctitle(IV, `var', all controls, regions FE) bdec(3) nocons excel tex addstat(F-statistic, e(widstat))  `append'
  
ivreg2  evol2_fn_2012_2017 ( CAO CAO_size= num_group_vv num_group_vv_size)      coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_    CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_    i.reg, cluster( numdep) first

qui outreg2 using "Table 3", ///
keep( CAO CAO_size) ctitle(IV, `var', all controls, regions FE) bdec(3) nocons excel tex addstat(F-statistic, e(widstat))  `append'
  
restore   
   
   
***Bottom panel of Table 3 (descriptive statistics)***    
 
preserve
foreach var of varlist log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_  ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  {


drop if `var'==.


}
***

keep if period>=2

g missing_size=(tot_places_CAO_per1000==0&CAO==1)
tab missing_size, m

sum tot_places_CAO_per1000 if CAO==1, de
replace tot_places_CAO_per1000=0.0350716 if missing_size==1
sum tot_places_CAO_per1000  if CAO==1, de

g  tot_places_CAO_per1000_CAO= tot_places_CAO_per1000
replace tot_places_CAO_per1000_CAO=. if CAO==0

lab var tot_places_CAO_per1000 "Size every 1000 inhabitants"
lab var tot_places_CAO_per1000_CAO "Size every 1000 inhabitants if CAO==1"

sum tot_places_CAO_per1000 tot_places_CAO_per1000_CAO
sumstats (tot_places_CAO_per1000 tot_places_CAO_per1000_CAO) using "Table 3_descriptive statistics", replace stats( mean sd min max)
  
restore 
 
 
 **************
 ***Table A1***
 **************
 
preserve
foreach var of varlist log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_  ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  {


drop if `var'==.


}
***

keep if period<=2
 
reg log_fn  CAO_period_2 i.period   ///
log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_ ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ , cluster( codeinsee) absorb(codeinsee)
 
qui outreg2 using "Table A1", ///
keep(CAO_period_2) ctitle(controls, time FE, municipal FE) bdec(3) nocons excel tex `append'
restore

 
preserve
keep if period==3

foreach var of varlist  CAO num_group_vv evol2_fn_2012_2017 /// 
coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ ///
   CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ {

drop if `var'==.

}
***


 ***Reduced form***

reg  evol2_fn_2007_2012  num_group_vv       coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg, cluster( numdep)

qui outreg2 using "Table A1", ///
keep(num_group_vv) ctitle(Reduced Form, all controls, regions FE) bdec(3) nocons excel tex `append'  

ivreg2  evol2_fn_2007_2012 (CAO= num_group_vv)      coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_   i.reg, cluster( numdep) first

qui outreg2 using "Table A1", ///
keep(CAO) ctitle(IV, all controls, regions FE) bdec(3) nocons excel tex addstat(F-statistic, e(widstat)) `append'

restore 

   
 **************
 ***Table A3***
 **************
 
 preserve
 keep if period==3

foreach var of varlist  CAO num_group_vv evol2_fn_2012_2017 /// 
coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ ///
   CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ {

drop if `var'==.

}
***
 

 foreach var of varlist  evol2_fn_2012_2017 evol2_melench_2012_2017 {

    ivreg2 `var' (CAO= num_group_vv)      coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg if evol2_turnout<=0, cluster( numdep) first

qui outreg2 using "Table A3", ///
keep(CAO) ctitle(IV, all controls, regions FE, `var', below zero) bdec(3) nocons excel tex addstat(F-statistic, e(widstat)) `append'
 
   
   
   ivreg2 `var' (CAO= num_group_vv)      coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg if evol2_turnout>0, cluster( numdep) first

qui outreg2 using "Table A3", ///
keep(CAO) ctitle(IV, all controls, regions FE, `var', above zero) bdec(3) nocons excel tex addstat(F-statistic, e(widstat)) `append'
   


}
*** 

 restore
 

 **************
 ***Table A4***
 **************
 
 preserve
 keep if period==3

foreach var of varlist  CAO num_group_vv evol2_fn_2012_2017 /// 
coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ ///
   CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ {

drop if `var'==.

}
***
 
***Bottom panel of Table A4 (descriptive statistics)*** 
 
g num_group_vv_CAO= num_group_vv
replace num_group_vv_CAO=. if num_group_vv_CAO==0

lab var num_group_vv "# group buildings"
lab var num_group_vv_CAO "# group buildings>0"

sum num_group_vv num_group_vv_CAO
sumstats (num_group_vv num_group_vv_CAO) using "Table A4_descriptive statistics", replace stats( mean sd min max) 
 
 
***Regression results Table A4*** 
 

reg  CAO  num_group_vv       coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg if num_group_vv<191, cluster( numdep)
   
   test num_group_vv

qui outreg2 using "Table A4", ///
keep(num_group_vv) ctitle(First Stage, all controls, regions FE, Drop 5) bdec(3) nocons excel tex addstat(F-statistic, r(F))  `append' 


***

reg  CAO  num_group_vv       coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg if num_group_vv<132, cluster( numdep)
   
   test num_group_vv

qui outreg2 using "Table A4", ///
keep(num_group_vv) ctitle(First Stage, all controls, regions FE, Drop 10) bdec(3) nocons excel tex addstat(F-statistic, r(F))  `append' 



***

reg  CAO  num_group_vv       coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg if num_group_vv<85, cluster( numdep)
   
   test num_group_vv

qui outreg2 using "Table A4", ///
keep(num_group_vv) ctitle(First Stage, all controls, regions FE, Drop 30) bdec(3) nocons excel tex addstat(F-statistic, r(F))  `append' 

***


sum num_group_vv if num_group_vv>0, de
winsor2 num_group_vv if num_group_vv>0, replace cuts(1 99)
sum num_group_vv if num_group_vv>0, de

reg  CAO  num_group_vv       coastal  log_hotel_rooms    log_tot_pop_ delta_log_tot_pop  log_min_dist_center volontaires_migrants evol_CADA_2012_2016 share_0014_   share_60p_  delta_share_0014 ///
   delta_share_60p   share_csp1_ share_csp2_ share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_   delta_share_csp* share_chom1564_ delta_share_chom1564 migshare_ delta_migshare ///
   log_median_inc_ delta_log_median_in female_ age_ right_ CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  i.reg , cluster( numdep)
   
   test num_group_vv

qui outreg2 using "Table A4", ///
keep(num_group_vv) ctitle(First Stage, all controls, regions FE, Winsorized data) bdec(3) nocons excel tex addstat(F-statistic, r(F))  `append' 

 restore
 
 
 ***************
 ***Figure A2***
 ***************

preserve 
foreach var of varlist log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_ ///
share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_  ///
CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_  {


drop if `var'==.


}
***

keep if period>=2

g missing_size=(tot_places_CAO_per1000==0&CAO==1)
tab missing_size, m

sum tot_places_CAO_per1000 if CAO==1, de
replace tot_places_CAO_per1000=0.0350716 if missing_size==1
sum tot_places_CAO_per1000  if CAO==1, de

***create standardized version of size of the centre***

egen tot_places_CAO_per1000_st=std(tot_places_CAO_per1000)
g CAO_period_3_size=tot_places_CAO_per1000_st*CAO_period_3

interflex log_fn  CAO_period_3   tot_places_CAO_per1000_st period_2 period_3 log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_  ///
   share_csp3_ share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_   CSP_agri_ CSP_ind_ ///
   CSP_sal_ CSP_lib_ CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ , cutoffs( 7 12) xdistr(density) cluster(codeinsee) fe(codeinsee) ///
    dlabel(CAO) ylabel(Log(FN)) xlabel((CAO-migrants/population)) 
   

capture graph save interflex_1.gph,replace	

   
 interflex log_fn  CAO_period_3   tot_places_CAO_per1000_st period_2 period_3 log_tot_pop_  share_0014_     share_60p_  share_csp1_ share_csp2_    share_csp3_ ///
 share_csp4_ share_csp5_ share_csp6_ share_csp7_ share_csp8_ share_chom1564_  migshare_  log_median_inc_ female_ age_ right_   CSP_agri_ CSP_ind_ CSP_sal_ CSP_lib_ /// 
 CSP_ens_ CSP_func_ CSP_div_ CSP_retr_ , cutoffs( 12 17) xdistr(density) cluster(codeinsee) fe(codeinsee)  ///
    dlabel(CAO) ylabel(Log(FN)) xlabel((CAO-migrants/population))

  capture graph save interflex_2.gph,replace	
	  
graph combine  interflex_1.gph  interflex_2.gph , graphregion(color(white)) plotregion(color(white))
graph save interflex_all,replace
graph export "Figure A2.pdf", replace
 
restore 

log close
